﻿using System.Globalization;

namespace FBA.Client.Utils
{
    public partial class PropertyUtils
    {
        /// <summary>
        /// 把字符串的命名规则转换为c#驼峰命名法
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string ToCamelCase(string name)
        {
            if (name.Contains("_"))
            {
                return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name.Replace("_", " ")
                    .ToLower()) //单词首字母大写
                    .Replace(" ", ""); //去掉空格
            }
            else
            {
                return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name.ToLower());
            }
        }
    }
}
